<template>
  <router-view :menuList="menuList" :menu="menu" ref="router" />
</template>

<script>

export default {
  data() {
    return {
      menuList: [],
      menu: {
        activeName: 'index2',
        openNames: []
      }
    }
  },
  mounted() {
    let token = localStorage.getItem('token'), fullPath = this.$route.path, menu = localStorage.getItem('menu');
    if (token) {
      this.$submit('/admin/login/isLogin', {}, res => {
        if (res.data.status == '10000') {
          if (fullPath == '/admin/login') {
            this.$jumpUrl({ path: '/admin/index' });
          }
        } else {
          localStorage.clear();
          if (fullPath != '/admin/login') this.$router.push({ path: '/admin/login' }).catch(() => { });
        }
      })
    } else if (fullPath != '/admin/login') {
      this.$router.push({ path: '/admin/login' }).catch(() => { });
    }
    if (!menu) {
      localStorage.clear();
      this.$router.push({ path: '/admin/login' }).catch(() => { });
    } else {
      this.menuList = JSON.parse(menu);
    }
  }
}
</script>

<style scoped>
</style>
